<template>
  <div class="internship">
    <el-card class="box-card">
      <!-- 查询区 -->
      <el-form ref="queryFormRef" :model="queryInfo" size="small" :inline="true">
        <el-form-item label="员工编号" prop="id">
          <el-input
            v-model="queryInfo.id"
            clearable
            @keyup.enter.native="handleQuery"
            placeholder="请输入员工编号搜索"
          ></el-input>
        </el-form-item>
        <el-form-item label="员工姓名" prop="empName">
          <el-input
            v-model="queryInfo.empName"
            @keyup.enter.native="handleQuery"
            clearable
            placeholder="请输入员工姓名搜索"
          ></el-input>
        </el-form-item>
        <el-form-item label="部门" prop="deptId">
          <dept-select :value.sync="queryInfo.deptId" style="width:200px" />
        </el-form-item>
        <el-form-item label="岗位" prop="staId">
          <station-select :value.sync="queryInfo.staId" />
        </el-form-item>
        <el-form-item>
          <el-button size="mini" type="primary" @click="handleQuery">查询</el-button>
          <el-button size="mini" @click="handleReset('queryFormRef')">重置</el-button>
        </el-form-item>
      </el-form>
      <!-- 表格 -->
      <el-table
        :data="employeesDataList"
        tooltip-effect="dark"
        :header-cell-style="{ background: '#f8f8f9', color: '#515a6e' }"
        style="width: 100%;"
        v-loading="loading"
      >
        <el-table-column label="员工编号" prop="id" width="120" align="center"></el-table-column>
        <el-table-column label="员工姓名" prop="empName" width="150" align="center"></el-table-column>
        <el-table-column label="部门名称" prop="deptName" width="150" align="center"></el-table-column>
        <el-table-column label="岗位名称" prop="staName" width="150" align="center"></el-table-column>
        <el-table-column label="考核结果" width="150" align="center">
          <template>转正</template>
        </el-table-column>
        <el-table-column label="转正日期" align="center" width="100">
          <template slot-scope="{row}">{{row.operDate | formatDate }}</template>
        </el-table-column>
        <el-table-column
          label="考核评语"
          prop="comment"
          width="150"
          :show-overflow-tooltip="true"
          align="center"
        ></el-table-column>
        <el-table-column label="备注" prop="remark" align="center"></el-table-column>
        <el-table-column label="操作人" prop="operName" align="center"></el-table-column>
      </el-table>
      <el-pagination
        @size-change="getEmployeeInfoList"
        @current-change="getEmployeeInfoList"
        :current-page.sync="queryInfo.pageNum"
        :page-sizes="[10, 20, 30]"
        :page-size.sync="queryInfo.pageSize"
        layout="total, sizes, prev, pager, next, jumper"
        :total="total"
      ></el-pagination>
    </el-card>
  </div>
</template>

<script>
import { listRightInternshipApi } from "@/api/internship";
export default {
  name: "",
  data() {
    return {
      queryInfo: {
        // 当前页
        pageNum: 1,
        // 页大小
        pageSize: 10,
        // // 员工编号
        id: undefined,
        // // 员工姓名
        empName: undefined,
        // // 部门名称
        deptId: undefined,
        // // 岗位名称
        staId: undefined,
      },
      employeesDataList: [],
      total: 0,
      loading: false,
    };
  },
  created() {
    this.getEmployeeInfoList();
  },
  methods: {
    async getEmployeeInfoList() {
      try {
        this.loading = true;
        const { data, code } = await listRightInternshipApi(this.queryInfo);
        if (code !== 200) return;
        console.log(data);
        this.employeesDataList = data.datas;
        this.total = data.total;
      } finally {
        this.loading = false;
      }
    },
    handleQuery() {
      this.getEmployeeInfoList();
    },
    handleReset(formName) {
      this.$refs[formName].resetFields();
      this.getEmployeeInfoList();
    },
  },
};
</script>

<style scoped lang="scss">
.el-pagination {
  margin-top: 20px;
}
</style>
